package com.cmpan.networkdisk.service;

import com.cmpan.networkdisk.dao.DynamicMapper;
import com.cmpan.networkdisk.model.Dynamic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * ClassName:DynamicServiceImp
 * Package:com.cmpan.networkdisk.service
 * Description:
 *
 * @Date:2020/7/19 13:33
 * @com.chuangmei
 */
@Service
public class DynamicServiceImp implements DynamicService{

    @Resource
    private DynamicMapper dynamicDao;

    @Override
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
    public int addDynamic(Dynamic dynamic) {

        int count = dynamicDao.insertSelective(dynamic);

        return count;
    }

    @Override
    public List<Dynamic> queryAll() {

        List<Dynamic> dynamics = dynamicDao.selectAll();

        return dynamics;
    }
}
